import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/components/login.vue'
import Home from '@/components/Home.vue'
<<<<<<< HEAD
=======
import Welcome from '@/view/Welcome.vue'
import Users from '@/view/user/Users.vue'
import Rights from '@/view/power/Rights.vue'
import Roles from '@/view/power/Roles.vue'
import Cate from '@/view/goods/Cate.vue'
import Params from '@/view/goods/Params.vue'
import Goods from '@/view/goods/Goods.vue'
import Add from '@/view/goods/Add.vue'
import Orders from '@/view/order/Orders.vue'
import Reports from '@/view/report/Reports.vue'

>>>>>>> final
// import { pathList } from '@/assets/toPath.js'

Vue.use(VueRouter)

const routes = [
  { path: '/login', component: Login },
  { path: '/', redirect: '/login' },
<<<<<<< HEAD
  { path: '/home', component: Home }
=======
  {
    path: '/home',
    component: Home,
    redirect: '/welcome',
    children: [
      { path: '/welcome', component: Welcome },
      { path: '/users', component: Users },
      { path: '/rights', component: Rights },
      { path: '/roles', component: Roles },
      { path: '/categories', component: Cate },
      { path: '/params', component: Params },
      { path: '/goods', component: Goods },
      { path: '/goods/add', component: Add },
      { path: '/orders', component: Orders },
      { path: '/reports', component: Reports }
    ]
  }
>>>>>>> final
]

const router = new VueRouter({
  routes
})

// 前置导航守卫
router.beforeEach((to, from, next) => {
  if (to.path === '/login') {
    next()
  }
  const token1 = window.sessionStorage.getItem('token')
  if (!token1) return next('/login')
  next()
})
export default router
